﻿namespace Service.Framework.Utils.Extension
{
    public static class IntExtension
    {
        /// <summary>
        /// 获取总页数
        /// </summary>
        /// <param name="totalCount"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        public static Int32 GetTotalPage(this Int32 totalCount, Int32 pageSize)
        {
            return totalCount % pageSize == 0 ?
                totalCount / pageSize : (totalCount / pageSize) + 1;
        }

        /// <summary>
        /// 获取行号
        /// </summary>
        /// <param name="num">第n个</param>
        /// <param name="pageSize">页码大小</param>
        /// <param name="pageIndex">第n页</param>
        /// <returns></returns>
        public static Int32 GetRowNum(this Int32 num, Int32 pageSize, Int32 pageIndex)
        {
            return pageSize * (pageIndex - 1) + num;
        }


    }
}
